<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePersonalRecordingTable extends Migration{
    /**
     * 作者 柯良志
     * 个人用户  记录表
     * 添加时间 2016-7-28
     */
    public function up(){
        /** 邀约面试记录表 interview   **/
        Schema::create('interview', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->integer('company_uid')->unsigned()->index('company_uid')->default(0)->comment('所属企业会员uid');
            $table->integer('com_id')->unsigned()->index('com_id')->default(0)->comment('所属企业id');
            $table->integer('personal_uid')->unsigned()->index('personal_uid')->default(0)->comment('所属个人会员uid');
            $table->integer('resume_id')->unsigned()->index('resume_id')->default(0)->comment('所属简历id');
            $table->integer('job_id')->unsigned()->index('job_id')->default(0)->comment('所属职位id');
            $table->timestamp('interview_time')->nullable()->comment('面试时间');
            $table->tinyInteger('status')->unsigned()->default(0)->comment('0未处理/1已查看/2同意邀约/3已被婉拒/4已删除');
            $table->text('remark')->default('')->comment('备注');
            $table->timestamps();
        });

        /** 浏览简历记录表 browse_resume  **/
        Schema::create('browse_resume', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->integer('company_uid')->unsigned()->index('company_uid')->default(0)->comment('所属企业会员uid');
            $table->integer('com_id')->unsigned()->index('com_id')->default(0)->comment('所属企业id');
            $table->integer('personal_uid')->unsigned()->index('personal_uid')->default(0)->comment('所属个人会员uid');
            $table->integer('resume_id')->unsigned()->index('resume_id')->default(0)->comment('所属简历id');
            $table->timestamps();
        });

        /** 职位收藏夹表 favorites   **/
        Schema::create('favorites', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->integer('uid')->unsigned()->index('uid')->default(0)->comment('所属个人会员uid');
            $table->integer('com_id')->unsigned()->index('com_id')->default(0)->comment('所属企业id');
            $table->integer('job_id')->unsigned()->index('job_id')->default(0)->comment('所属职位id');
            $table->timestamps();
        });

        /** 简历投递记录表 resume_send  **/
        Schema::create('resume_send', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->integer('company_uid')->unsigned()->index('company_uid')->default(0)->comment('所属企业会员uid');
            $table->integer('com_id')->unsigned()->index('com_id')->default(0)->comment('所属企业id');
            $table->integer('personal_uid')->unsigned()->index('personal_uid')->default(0)->comment('所属个人会员uid');
            $table->integer('resume_id')->unsigned()->index('resume_id')->default(0)->comment('所属简历id');
            $table->integer('job_id')->unsigned()->index('job_id')->default(0)->comment('所属职位id');
            $table->tinyInteger('status')->unsigned()->default(0)->comment('0未处理/1已查看/2同意邀约/3已被婉拒/4已删除');
            $table->timestamps();
        });

        /** 浏览企业记录表 browse_company  **/
        Schema::create('browse_company', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->integer('company_uid')->unsigned()->index('company_uid')->default(0)->comment('所属企业会员uid');
            $table->integer('com_id')->unsigned()->index('com_id')->default(0)->comment('所属企业id');
            $table->integer('personal_uid')->unsigned()->index('personal_uid')->default(0)->comment('所属个人会员uid');
            $table->integer('resume_id')->unsigned()->index('resume_id')->default(0)->comment('所属简历id');
            $table->timestamps();
        });

        /** 浏览职位记录表 browse_job **/
        Schema::create('browse_job', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->integer('company_uid')->unsigned()->index('company_uid')->default(0)->comment('所属企业会员uid');
            $table->integer('com_id')->unsigned()->index('com_id')->default(0)->comment('所属企业id');
            $table->integer('personal_uid')->unsigned()->index('personal_uid')->default(0)->comment('所属个人会员uid');
            $table->integer('resume_id')->unsigned()->index('resume_id')->default(0)->comment('所属简历id');
            $table->integer('job_id')->unsigned()->index('job_id')->default(0)->comment('所属职位id');
            $table->timestamps();
        });

        /** 企业人才库/简历收藏夹 resume_favorite **/
        Schema::create('resume_favorite', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->integer('uid')->unsigned()->index('uid')->default(0)->comment('所属企业会员uid');
            $table->integer('resume_id')->unsigned()->index('resume_id')->default(0)->comment('所属简历id');
            $table->integer('job_id')->unsigned()->index('job_id')->default(0)->comment('所属职位id(可选)');
            $table->tinyInteger('status')->unsigned()->default(0)->comment('0正常/4删除');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     * @return void
     */
    public function down(){
        Schema::drop('interview');
        Schema::drop('browse_resume');
        Schema::drop('favorites');
        Schema::drop('resume_send');
        Schema::drop('browse_company');
        Schema::drop('browse_job');
        Schema::drop('resume_favorite');
    }
}
